<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>组织管理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	
	<link rel="stylesheet" href="css/vivo.css">
	<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
	<link rel="stylesheet" href="js/bootstrap2/css/bootstrap-table.css">
	<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	
	<script src="js/jquery-1.11.1.js"></script>
	<script src="js/bootstrap2/js/bootstrap.min.js"></script>
	<script src="js/bootstrap2/js/bootstrap-table.js"></script>
	<script src="js/bootstrap2/js/bootstrap-table-zh-CN.js"></script>
	<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script> 
	<script src="js/select2/select2.min.js"></script>
	<script src="js/sharefunction.js"></script>
	<style type="text/css">
		th {
			color: white;
			background-color: #F08080
		}
		.table-striped tbody>tr:nth-child(odd)>td {
			background-color: #EDEDED;
		}
		.table th, .table td {
			text-align: center;
			vertical-align: middle !important;
		}
		.bootstrap-table {
			width: 98%
		}
	</style>
  </head>
	<body style='height:100%'>
	<div> 
		<a  class="btn btn-danger" href="admin/org/dept/add">新增</a> 
		<div>
			<div>
				<!-- 列表start -->
				<div style="margin-top: 15px;">
					<div>
						<!-- 信息列表 -->
						<table id="table">
						</table>
					</div>
					<script type="text/javascript">
						var fkcustomerId;
						var fkroomId;
						//表格-操作 - 格式化 
						function actionFormatter(value, row, index) {
							var html = '';
							<shiro:hasPermission name="permission:edit"> 
								html = '<a class="btn btn-info"  href="admin/org/dept/add?id='+row.id+'">编辑</a>&nbsp;&nbsp;'
							</shiro:hasPermission> 
							<shiro:hasPermission name="permission:delete"> 
								html += '<a class="btn btn-danger" onclick=del("'+row.id+'"); >删除</a>';
							</shiro:hasPermission>  
							return html;
						}
						//日期格式化
						function dataFormat(value, row, index){
							return new Date(row.createDate).format("yyyy-MM-dd");
						}
						function edit(id){
							$("#toAddDept").show();
							$("iframe[id='addDept']").attr("src", "admin/org/dept/add?id="+id);
						}
						
						//删除
						function del(id){
							if(confirm("您确认要删除吗？")){
								var url = "admin/org/dept/delete";
								var msg = AjaxDeleleAction(url,id);
								alert(msg);
								location.href=location.href;
							}
						}
						
						$(function() {
							fkcustomerId = parent.$("#customerId").val();
							fkroomId = parent.$("#roomId").val();
							//先销毁表格  
							//$('#table').bootstrapTable('destroy');  
							//初始化表格,动态从服务器加载数据  
							$("#table").bootstrapTable({
								method : "post", //使用get请求到服务器获取数据  
								url : "admin/org/dept/alljson", //获取数据的Servlet地址  
								striped : true, //表格显示条纹  
								pagination : true, //启动分页  
								pageSize : 15, //每页显示的记录数  
								pageNumber : 1, //当前第几页  
								pageList : [ 5, 10, 15, 20, 50, 100  ], //记录数可选列表  
								sidePagination : "client", //表示客户服务端请求  
								contentType : 'application/x-www-form-urlencoded',
								//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder  
								//设置为limit可以获取limit, offset, search, sort, order  
								queryParamsType : "undefined",
								queryParams : function queryParams(params) { //设置查询参数  
									var param = {
										pageNumber : params.pageNumber,
										pageSize : params.pageSize
									};
									return param;
								},
								columns : [ {
									field : 'orgName',
									title : '组织名称',
									width : '30%',
									align : 'left'
								}, {
									field : 'orgCode',
									title : '组织编码',
									width : '20%'
								}, {
									field : 'createTime',
									title : '创建时间'
								}, {
									field : 'opr',
									title : '操作',
									width : '15%',
									formatter : 'actionFormatter'
								} ]
							});
						})
					</script>
					
				</div>
				<!-- 列表end -->
				<!-- 表单start -->
				<!-- <div id="toAddDept" hidden="hidden" style="margin-top: 15px;height: 500px">
					<iframe id="addDept" name="addDept" width="100%"
						style="height:100%;" frameborder="0"></iframe>
				</div> -->
				<!-- 表单end -->
			</div>
		</div>
	</div>
	<script type="text/javascript">
		/* function openAddDept(){
			$("#toAddDept").show();
			$("iframe[id='addDept']").attr("src", "admin/org/dept/add");
		} */
	</script>
	</body>
</html>